package login;

import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.AssertTrue;

public class User {
//    @NotEmpty(message="用户名不能为空")
    //@Length(max=14,min=8,message="用户名长度在8-14之间")
    @Length(max=14,min=8)
    String username;//用户名

//    @Length(max=14,min=8,message="密码长度在8-14之间")
    @Length(max=14,min=8)
    String password;//密码

//    @AssertTrue(message = "且密码不能和用户名一致")
    @AssertTrue
    public boolean isSamePassword1() {
        System.out.println("密码："+password);
        if (password == null || password == ""){
            return true;
        }else if ( !username.equals(password)) {
            return true;
        } else {
            return false;
        }
    }

//    @AssertTrue(message = "两次密码输入不一致")
    @AssertTrue
    public boolean isSamePassword() {
        if (password != null && password.equals(password2)) {
            return true;
        } else {
            return false;
        }
    }
    String password2;//确认密码
    String sex;//性别
    String work;//职业
    String favorite;//个人爱好
    String note;//说明

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPassword2() {
        return password2;
    }

    public void setPassword2(String password2) {
        this.password2 = password2;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getWork() {
        return work;
    }

    public void setWork(String work) {
        this.work = work;
    }

    public String getFavorite() {
        return favorite;
    }

    public void setFavorite(String favorite) {
        this.favorite = favorite;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }
}
